<template>
  <div id="">
    <p style="text-align:center; padding:40px 0;">
    正在登录...
    </p>
  </div>
</template>
<script>
import { getQueryString } from '@/util/util.js';
import { mapState,mapMutations } from 'Vuex';
export default {
  name: "",
  data: () => ({

  }),
  mounted() {
    //do something after mounting vue instance
    let that = this;

    //已注册
    // http://rh.klbkvg.cn/loginOpenid?token=fjakfjaklsgjakds
    // 未注册
    // http://rh.klbkvg.cn/loginOpenid?
    // openid=6a5e94365af4941619add5393a361b60ef020173621963af34e08673e3be352b
    // &icon=http://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTLmySEazOjOIVLJS8F9xib85SLA48BN8xcvCFGpqoEHV8PK9So3hhPUTu5pVNoYGk0wEhhWZGSDAIw/132#/
    let token = getQueryString('token');
    let openid = getQueryString('openid');
    let icon = getQueryString('icon');
    console.log(openid);
    console.log(token);
    console.log(icon);
    // 存到本地缓存
    // if(openid==null){   //已授权过，只需要更新token
    //
    // }else{    //第一次授权，保存openid
      window.localStorage.setItem('syOpenId',openid);
      window.localStorage.setItem('syIcon',icon);
    // }
    window.localStorage.setItem('userToken',token);
    setTimeout(function(){
      that.setRelogin();
      that.$router.push({name:'index'});
      console.log(window.history);
      // window.history.go(-2);
    },1000);
  },
  methods: {
    ...mapMutations([
      'setRelogin',    //是否重新登录
    ]),
  }
}
</script>
<style lang="scss" scoped>
</style>
